//
//  UIFont+Font.m
//  SafeFoodManagerDemo
//
//  Created by bob on 2017/9/15.
//  Copyright © 2017年 bob. All rights reserved.
//注释:此方法只对手写的有效

#import "UIFont+Font.h"
#import <YYCategories/NSObject+YYAdd.h>
@implementation UIFont (Font)

+(void)load
{
    [self swizzleClassMethod:@selector(systemFontOfSize:) with:@selector(TB_systemFontOfSize:)];
    
    [self swizzleClassMethod:@selector(boldSystemFontOfSize:) with:@selector(TB_boldSystemFontOfSize:)];
    
}

+ (UIFont *)TB_systemFontOfSize:(CGFloat)pxSize{
    
    /*
     ps和pt转换
     
     px:相对长度单位。像素（Pixel）。（PS字体）
     pt:绝对长度单位。点（Point）。（iOS字体）
     UI标记图上给我们字体的大小一般都是像素点，如图
     
     */
//    CGFloat pt = (pxSize/96.0)*72;
    
    CGFloat pt=pxSize;
    
    if ([UIScreen mainScreen].bounds.size.width>375) {
        
        //如果是iphone plus,字体增加1.2倍，其他的字体共用
        
        pt=pt*1.2 ;
    }else if ([UIScreen mainScreen].bounds.size.width==320)
    {
     
        pt=pt*0.8;
        
    }
    UIFont *font = [UIFont TB_systemFontOfSize:pt];

    return font;
}


+(UIFont*)TB_boldSystemFontOfSize:(CGFloat)pxSize
{
//    CGFloat pt = (pxSize/96.0)*72;

    CGFloat pt=pxSize;
    
    if ([UIScreen mainScreen].bounds.size.width>375) {
        pt=pt*1.2;
    }else if ([UIScreen mainScreen].bounds.size.width==320)
    {
        
        pt=pt*0.8;
        
    }
    UIFont *font = [UIFont TB_boldSystemFontOfSize:pt];
    
    return font;
}

@end
